#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/stat.h>
#include"lcd1602cmd.h"

#define DEV_NAME "/dev/lcd1602"
void lcd_init(int fd)
{
		ioctl(fd,SET_MODE, CUR_LEFT | SCRN );
		ioctl(fd,DISPLAY_CTL, DISP_ON | HAVE_CURSOR | HAVE_FLASH);
		ioctl(fd,SCREEN_MOVE_DIRECTION,SC_CLEAR | RL_SET);
		ioctl(fd,FUNCTION_CTL,DL_SET | N_SET | F_SET);
		
}
int main(int argc,char *arv[]){
	int fd = open(DEV_NAME, O_RDWR | O_NOCTTY | O_NDELAY);
	if(fd < 0)
	{
			printf("open file failed\n");
			return -1;
	}
	printf("open suceess\n");
	lcd_init(fd);
	char msg[] ={'A'};
	write(fd,msg,1);
	close(fd);
	return 0;
	
}
